import React from 'react'
import './Register.css'
import { Form, Input, Button, } from 'antd-mobile'
import {getRegister} from '../../request/index'
import { useNavigate } from 'react-router-dom'
import { LeftOutline } from 'antd-mobile-icons'
const Register = () => {
    
const navigate=useNavigate()
const onFinish=(values:any)=>{
    console.log(values);
    getRegister({}).then(res=>{
        console.log(res);
        window.location.href='/'
    })
}

    return (
        <div>
             <div>
                <span className='ioc' onClick={()=>(navigate(-1))}><LeftOutline /></span>
            </div>
            <Form
            onFinish={onFinish}
                layout='horizontal'
                footer={
                    <Button block type='submit' color='primary' size='large'>
                        注册
                    </Button>
                }
            >
                <Form.Item
                    name='username'
                    label='用户名'
                    rules={[{ required: true, message: '用户名不能为空' },
                    { min: 8, message: '用户名格式不对' }
                    ]}
                >
                    <Input  placeholder='请输入用户名' />
                </Form.Item>
                <Form.Item
                    name='password'
                    label='密码'
                    rules={[{ required: true, message: '密码不能为空' },
                    { min: 6, message: '密码不能少于6位' }
                    ]}
                >
                    <Input  placeholder='请输入密码' type="password"/>
                </Form.Item>

                 <Form.Item
                    name='passwor'
                    label='密码'
                    rules={[{ required: true, message: '确认二次密码' },
                    { min: 6, message: '密码不能少于6位' }
                    ]}
                >
                    <Input  placeholder='确认二次密码' type="password" />
                </Form.Item>
            </Form>
        </div>
    )
}

export default Register
